package com.wxr.controller;

import com.wxr.mapper.DeptMapper;
import com.wxr.pojo.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DeptController {

    @Autowired
    private DeptMapper deptMapper;

    @GetMapping("/queryDeptList")
    public List<Dept> queryDeptList(){
        List<Dept> depts = deptMapper.queryDeptList();
        return depts;
    }

    @GetMapping("/addDept")
    public String addDept(){
        deptMapper.addDept(new Dept(9,"mybatis测试","mybatis测试"));
        return "ok";
    }

    @GetMapping("/updateDept")
    public String updateDept(){
        deptMapper.updateDept(new Dept(8,"mybatis测试111","mybatis测试"));
        return "ok";
    }

    @GetMapping("/deleteDept")
    public String deleteDept(){
        deptMapper.deleteDept(6);
        return "ok";
    }

//    @GetMapping("/queryDeptById/${id}")
//    public List<Dept> queryDeptById(@PathVariable("id")){
//        List<Dept> depts = deptMapper.queryDeptList();
//        return depts;
//    }

}
